<?php

namespace app\adm\Controller;

use think\Db;

class Test
{
    public function index()
    {
        $data = [

            'ad_tel' => 'admin',
            'ad_pwd' => encrypt(),
        ];

        db('admin')->insert($data);
    }

    public function rlt()
    {
        $tel = '15838350135';

        $sms = config('sms');

        $sms['password'] = ucfirst(md5($sms['password']));
        $sms['mobile'] = $tel;

        $code = mt_rand(1234, 9876);
        $sms['content']  = '【健康360生活】尊敬的会员您好,您的验证码为：' . $code;
        $sms['sendTime'] = '';

        $query_str = http_build_query($sms);

        $gateway = "http://114.113.154.5/sms.aspx?action=send&".$query_str;
        $result = file_get_contents($gateway);
        $xml = simplexml_load_string($result);

        if ($xml->returnstatus == 'Faild') {
           echo $xml->message;
        }
        cache($tel.'code', $code, 120);
        echo '验证码'.$code.'已发送,两分钟内有效';
    }
}